#include <iostream>
using namespace std;

int main()
{

    int year = 0, month = 0, day = 0;
    int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    while (cin >> year >> month >> day)
    {
        int sum = 0;
        if (month >= 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
        {
            days[2] = 29;
        }
        for (int i = 1; i < month; i++)
        {
            sum += days[i];
        }
        sum += day;
        cout << sum << endl;
    }
    return 0;
}
